﻿Imports Org.BouncyCastle.Crypto.Generators
Imports Org.BouncyCastle.Crypto
Imports Org.BouncyCastle.Security
Imports Org.BouncyCastle.Crypto.Parameters

Public Class KeysAndDigestsUtilities

    Public Shared Function GenerateRSAKeypair(keylength As Integer) As AsymmetricCipherKeyPair
        Dim r As New RsaKeyPairGenerator()
        r.Init(New KeyGenerationParameters(New SecureRandom(), keylength))
        Dim keys As AsymmetricCipherKeyPair = r.GenerateKeyPair()
        Return keys
    End Function

    Public Shared Sub AsyncGenerateKey(keylength As Object)
        Dim key = GenerateRSAKeypair(DirectCast(keylength, Integer))
        RaiseEvent KeyGenerated(key)
    End Sub
    Public Shared Event KeyGenerated(key As AsymmetricCipherKeyPair)

End Class

